package com.group.www.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.group.www.dao.impl.OrderinfoDao;
import com.group.www.interfaces.OrderInfoServiceI;
import com.group.www.pojo.OrderInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@com.alibaba.dubbo.config.annotation.Service
@Service
public class SimpleOrderinfoService implements OrderInfoServiceI {

    @Autowired
    private SimpleOrderinfo_qService simpleOrderinfo_qService;

    @Autowired
    private OrderinfoDao orderinfoDao;

    @Override
    public boolean add(OrderInfo entity) {
        return simpleOrderinfo_qService.add(entity);
    }

    @Override
    public boolean update(OrderInfo entity) {
        return simpleOrderinfo_qService.update(entity);
    }

    @Override
    public List<OrderInfo> query() {
        return simpleOrderinfo_qService.query();
    }

    @Override
    public boolean delete(OrderInfo entity) {
        return simpleOrderinfo_qService.delete(entity);
    }

    @Override
    public boolean deleteMany(String ids) {
        if("".equals(ids) || null==ids){
            return false;
        }
        for (String id :ids.split(",")) {
            OrderInfo orderInfo = new OrderInfo();
            orderInfo.setOrderid(Integer.parseInt(id));
            simpleOrderinfo_qService.delete(orderInfo);
        }
        return true;
    }

    @Override
    public PageInfo<OrderInfo> queryAll(Integer brandid, Integer pageIndex, Integer pageSize, Object username, Object orderstatus) {
        PageHelper.startPage(pageIndex,pageSize,true);
        List<OrderInfo> orderInfos = orderinfoDao.queryAll(brandid, username, orderstatus);
        PageInfo<OrderInfo> orders=new PageInfo<>(orderInfos);
        return orders;
    }

    @Override
    public boolean amendOrderInfoStatusById(int orderid, int ostatusid) {
        //this.simpleOrderinfo_qService.amendOrderInfoStatusById(orderid,ostatusid);

        return false;
    }

}
